# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libplacebo
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.104.0
pkgrel=3
pkgdesc="Reusable library for GPU-accelerated video/image rendering primitives (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://code.videolan.org/videolan/libplacebo"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-glslang"
         "${MINGW_PACKAGE_PREFIX}-lcms2"
         "${MINGW_PACKAGE_PREFIX}-libepoxy"
         "${MINGW_PACKAGE_PREFIX}-shaderc"
         "${MINGW_PACKAGE_PREFIX}-spirv-tools"
         "${MINGW_PACKAGE_PREFIX}-vulkan")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-python-mako"
             "${MINGW_PACKAGE_PREFIX}-vulkan-headers")
license=('LGPLv2.1')
source=("https://code.videolan.org/videolan/libplacebo/-/archive/v${pkgver}/libplacebo-v${pkgver}.tar.gz")
sha256sums=('55559d77d893d3f13f0a15ff6ff3b462451f8996bd3e0b8b6794a65502341aaf')

prepare() {
  cd "${srcdir}/${_realname}-v${pkgver}"

}

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}

  local _incdir="$(cygpath -wm ${MINGW_PREFIX}/include/glslang)"

  CFLAGS+=" -I${_incdir}" \
  CXXFLAGS+=" -I${_incdir}" \
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dlcms=enabled \
    -Dglslang=enabled \
    -Dshaderc=enabled \
    -Dvulkan=enabled \
    "../${_realname}-v${pkgver}"

  ${MINGW_PREFIX}/bin/ninja.exe
}

package() {
  cd "${srcdir}"/build-${CARCH}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/ninja.exe install

  install -Dm644 "${srcdir}/${_realname}-v${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
